/*
 * ImageCache.h
 *
 *   This is free software; you can redistribute it and/or
 *   modify it under the terms of the GNU Lesser General Public
 *   License as published by the Free Software Foundation; either
 *   version 2 of the License, or (at your option) any later version.
 *
 *   This software is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *   Lesser General Public License for more details.
 *
 *  Created on: 2010-1-2
 *      Author: Huang Haiyang
 */

#ifndef IMAGECACHE_H_
#define IMAGECACHE_H_

#include <e32base.h>
#include <coemain.h>

#include "data\PNG.h"

namespace resource
	{
	
	class CImageCache : public CCoeStatic
		{
		enum {EImageCacheUID = 1};
	public:
		static CImageCache* getInstance();
		
	private:
		CImageCache();
		
	public:
		virtual ~CImageCache();
		
		TSize GetImageSize(const TDesC& aTag) const;
		data::CPNG* GetImage(const TDesC& aTag);
		
	private:
		data::CPNG* GetCachedImage(const TDesC& aTag) const;
		data::CPNG* LoadImageToCache(const TDesC& aTag);
		
		static void FullFillImagePath(TFileName& aResult, const TDesC& aTag);
		
	private:
		RPointerArray<data::CPNG>     iCachedImages;
		};

	}

#endif /* IMAGECACHE_H_ */
